function valCad(){
	$("#formCad").validate({
		rules: {
			cadNome: {
				required: true,
				minlength: 3,
				maxlength: 20,
				loginRegex: true
			},
			cadEmail: {
				required: true,
				email: true,
				maxlength: 60,
				loginRegex: true
			},
			cadSenha: {
				required: true,
				minlength: 6,
				maxlength: 16,
				loginRegex: true
			},
			cadResenha: {
				required: true,
				minlength: 6,
				maxlength: 16,
				loginRegex: true,
				equalTo: '#cadSenha'
			}
		}
	});

	$("#formLog").validate({
		rules: {
			logEmail: {
				required: true,
				email: true,
				maxlength: 60,
				loginRegex: true
			},
			logSenha: {
				required: true,
				minlength: 6,
				maxlength: 16,
				loginRegex: true
			}
		}
	});

	$("#btn-cadastrar").click(function(){
		if($("#formCad").valid()){
			inserir();
		}
	});
	$("#btn-logar").click(function(){
		if($("#formLog").valid()){
			logar();
		}
	});

}
function valLog(){
	$("#cadNome").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-cadastrar").click();
          }
        });

		$("#cadEmail").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-cadastrar").click();
          }
        });

        $("#cadSenha").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-cadastrar").click();
          }
        });

        $("#cadResenha").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-cadastrar").click();
          }
        });

        $("#logEmail").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-logar").click();
          }
        });

        $("#logSenha").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-logar").click();
          }
        });
}

function nit(){
	$.validator.addMethod("loginRegex", function(value, element) {
        return this.optional(element) || /^[a-z0-9\-\_\@\.-]+$/i.test(value);
    }, "Apenas numeros e letras");


	$("#formCad").validate({
		rules: {
			cadNome: {
				required: true,
				minlength: 3,
				maxlength: 5,
				loginRegex: true
			},
			cadEmail: {
				required: true,
				email: true,
				loginRegex: true
			},
			cadSenha: {
				required: true,
				minlength: 6,
				maxlength: 16,
				loginRegex: true
			},
			cadResenha: {
				required: true,
				minlength: 6,
				maxlength: 16,
				loginRegex: true,
				equalTo: '#cadSenha'
			}
		}
	});

	$("#formLog").validate({
		rules: {
			logEmail: {
				required: true,
				email: true,
				loginRegex: true
			},
			logSenha: {
				required: true,
				minlength: 6,
				maxlength: 16,
				loginRegex: true
			}
		}
	});
	//clickCadastrar();
	//clickLogar();


	/*
	//adicionando atalho ENTER
	$("#cadNome").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-cadastrar").click();
          }
        });

		$("#cadEmail").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-cadastrar").click();
          }
        });

        $("#cadSenha").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-cadastrar").click();
          }
        });

        $("#cadResenha").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-cadastrar").click();
          }
        });

        $("#logEmail").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-logar").click();
          }
        });

        $("#logSenha").keyup(function(event){
          if(event.keyCode == 13){
            $("#btn-logar").click();
          }
        });
	*/


}